<?php
	/* Functions in this file */
	/**************************/

	// GetColor()
	// GetFaceName()
	// GetMFCClassName()
	// GetMFCClassSchema()
	// GetPointSize()
	// GetWeight()
	// IsItalic()
	// IsStrikeOut()
	// IsUnderline()
	// IsValidPointSize($pointSize)
	// IsValidWeight($weight)
	// SetColor($color)
	// SetFaceName($faceName)
	// SetPointSize($pointSize)
	// SetWeight($weight)
?>
 
<?php
	 
	 
	class FontSetting {
		 
		 
		// Constants
		 
		 
		// Default constants
		const DEFAULT_FACENAME = "Times New Roman";
		const DEFAULT_POINTSIZE = 8;
		const DEFAULT_WEIGHT = self::weightNormal;
		const DEFAULT_ITALIC = 0;
		const DEFAULT_UNDERLINE = 0;
		const DEFAULT_STRIKEOUT = 0;
		static protected $DEFAULT_COLOR = array (0, 0, 0);
		 
		// Point Size constants
		const MIN_POINTSIZE = 1;
		const MAX_POINTSIZE = 72;
		 
		// Font $weight constants
		 
		const weightDontCare = 0;
		const weightThin = 100;
		const weightExtraLight = 200;
		const weightUltraLight = 200;
		const weightLight = 300;
		const weightNormal = 400;
		const weightRegular = 400;
		const weightMedium = 500;
		const weightSemiBold = 600;
		const weightDemiBold = 600;
		const weightBold = 700;
		const weightExtraBold = 800;
		const weightUltraBold = 800;
		const weightBlack = 900;
		const weightHeavy = 900;
		 
		// Member Variables
		 
		protected $m_faceName = self::DEFAULT_FACENAME;
		protected $m_pointSize = self::DEFAULT_POINTSIZE;
		protected $m_weight = self::DEFAULT_WEIGHT;
		protected $m_italic = self::DEFAULT_ITALIC;
		protected $m_underline = self::DEFAULT_UNDERLINE;
		protected $m_strikeOut = self::DEFAULT_STRIKEOUT;
		protected $m_color = array (0, 0, 0);
		 
		 
		 
		// MFC Class Functions
		 
		 
		function GetMFCClassName() {
			return "CFontItem";
		}
		 
		 
		function GetMFCClassSchema() {
			return 1;
		}
		 
		// Serialization Functions
		 
		 
		 
		 
		function SetFaceName($faceName) {
			if (!$faceName) return 0;
			$this->m_faceName = $faceName;
			 return 1;
		}
		 
		 
		function GetFaceName() {
			return ($this->m_faceName);
		}
		 
		// Point Size Functions
		 
		 
		 
		function IsValidPointSize($pointSize) {
			return (($pointSize >= self::MIN_POINTSIZE) && ($pointSize <= self::MAX_POINTSIZE));
		}
		 
		 
		 
		function SetPointSize($pointSize) {
			if (!$this->IsValidPointSize($pointSize)) return 0;
			$this->m_pointSize = $pointSize;
			 return 1;
		}
		 
		 
		function GetPointSize() {
			return ($this->m_pointSize);
		}
		 
		// Weight Functions
		 
		 
		 
		function IsValidWeight($weight) {
			return ((($weight >= self::weightDontCare) && ($weight <= self::weightHeavy)) && (($weight % 100) == 0));
		}
		 
		 
		 
		function SetWeight($weight) {
			if (!$this->IsValidWeight($weight)) return 0;
			$this->m_weight = $weight;
			 return 1;
		}
		 
		 
		function GetWeight() {
			return ($this->m_weight);
		}
		 
		// Effects Functions
		 
		 
		function SetItalic($set = 1) {
			$this->m_italic = $set;
		}
		 
		 
		function IsItalic() {
			return ($this->m_italic == true);
		}
		 
		 
		function SetUnderline($set = 1) {
			$this->m_underline = $set;
		}
		 
		 
		function IsUnderline() {
			return ($this->m_underline == true);
		}
		 
		 
		function SetStrikeOut($set = 1) {
			$this->m_strikeOut = $set;
		}
		 
		 
		function IsStrikeOut() {
			return ($this->m_strikeOut == 1);
		}
		 
		// Color Functions
		 
		 
		function SetColor($color) {
			$this->m_color = $color;
		}
		 
		 
		function GetColor() {
			return ($this->m_color);
		}
		 
		// Operations
		 
		 
		 
		function FontSetting($faceName = NULL, $pointSize = NULL, $weight = NULL, $italic = NULL, $underline = NULL, $strikeOut = NULL, $color=NULL) {
			 
			//------Last Checked------//
			// - Dec 6, 2004
			if (!$faceName) return 0;
			if (!$this->IsValidPointSize($pointSize)) return 0;
			if (!$this->IsValidWeight($weight)) return 0;
			
			if (!$color) $color = $this->DEFAULT_COLOR;
			 			
			 
			/*$this->m_faceName = $faceName;
			$this->m_pointSize = $pointSize;
			$this->m_weight = $weight;
			$this->m_italic = $italic;
			$this->m_underline = $underline;
			$this->m_strikeOut = $strikeOut;
			$this->m_color = $color;*/
		}
		 
		 
		
		function DoSerialize(&$stream){
		 
			WRITE_CSTRING ($stream,$this->m_faceName);

			WRITE_SIGNED_INTEGER ($stream,$this->m_pointSize);
			WRITE_SIGNED_INTEGER ($stream,$this->m_weight);
			WRITE_BYTE ($stream,$this->m_italic);
			WRITE_BYTE ($stream,$this->m_underline);
			WRITE_BYTE ($stream,$this->m_strikeOut);

			WRITE_COLOR_REF ($stream,$this->m_color);

			return 1;
		}
		
		 
		function DoDeserialize(&$stream){
		 
		
			$this->m_faceName = READ_CSTRING ($stream);
		
			$this->m_pointSize = READ_SIGNED_INTEGER ($stream);
			$this->m_weight = READ_SIGNED_INTEGER ($stream);
			$this->m_italic = READ_BYTE ($stream);
			$this->m_underline = READ_BYTE ($stream);
			$this->m_strikeOut = READ_BYTE ($stream);
		 
			READ_COLOR_REF ($stream, $this->m_color);
		
		}
		 
		 
		 
		 
		function SetFontSetting($faceName, $pointSize, $weight, $italic, $underline, $strikeOut, $color) {
			 
			//------Last Checked------//
			// - Dec 6, 2004
			if (!$this->SetFaceName($faceName))
				return 0;
			if (!$this->SetPointSize($pointSize))
				return 0;
			if (!$this->SetWeight($weight))
				return 0;
			$this->SetItalic($italic);
			$this->SetUnderline($underline);
			$this->SetStrikeOut($strikeOut);
			$this->SetColor($color);
			 
			return 1;
		}
		 
		 
		 
		 
	}
	 
?>

